package com.wy2.service.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wy2.entity.Student;
import com.wy2.entity.User;
import com.wy2.mapper.StudentMapper;
import com.wy2.service.StudentService;
import com.wy2.util.FenyeUtil;

@Service
public class StudentServiceImpl implements StudentService {

	@Autowired
	private StudentMapper studentmapper;
	/**
	 * 分页查询
	 */
	public FenyeUtil<Student> getAll(FenyeUtil<Student> fenye) {
		Integer count = studentmapper.getCount(fenye);
		List<Student> data = studentmapper.getData(fenye);
		if(data.size()>0) {
			fenye.setCount(count);
			fenye.setData(data);
		}else {
			fenye.setCode(1);
			fenye.setMsg("无数据");
		}
		return fenye;
	}
	/**
	 * 添加
	 */

	@Override
	public Integer addStudent(Student s) {
		// TODO Auto-generated method stub
		return studentmapper.addStudent(s);
	}
    /**
     * 删除
     */
	@Override
	public Integer delStudent(Integer sid) {
		// TODO Auto-generated method stub
		return studentmapper.delStudent(sid);
	}
     /**
      * 修改
      */
	@Override
	public Integer updStudent(Student s) {
		// TODO Auto-generated method stub
		return studentmapper.updStudent(s);
	}
   
	@Override
	public Integer importSingin(Student s) {
		// TODO Auto-generated method stub
		return studentmapper.importSingin(s);
	}

	@Override
	public Integer updateExt(Integer sid) {
		// TODO Auto-generated method stub
		return studentmapper.updateExt(sid);
	}
      
	@Override
	public FenyeUtil<Student> findByExt(FenyeUtil<Student> fenye) {
		
		List<Student> slist = studentmapper.findByExt(fenye);
		Integer count = studentmapper.getCountExt(fenye);
		fenye.setCount(count);
		fenye.setData(slist);
		fenye.setCode(0);
		fenye.setMsg("");
		return fenye;
	}

	@Override
	public Integer stuExt(Integer sid, String ext) {
		return studentmapper.stuExt(sid,ext);
	}

	@Override
	public Integer upFP(String zxsname, String zxid, String ids) {
		// TODO Auto-generated method stub
		List<String> idList = Arrays.asList(ids.split(","));
		return studentmapper.upFP(zxsname, zxid, idList);
	}

	@Override
	public Integer upZDFP(String zxsname, String zxid, Integer ids) {
		// TODO Auto-generated method stub
		return studentmapper.upZDFP(zxsname, zxid, ids);
	}

	@Override
	public List<Student> findByZxName(String zxname) {
		// TODO Auto-generated method stub
		return studentmapper.findByZxName(zxname);
	}

	@Override
	public void updateZxNameById(String ask, Integer sid) {
		// TODO Auto-generated method stub
		studentmapper.updateZxNameById(ask,sid);
	}
	@Override
	public FenyeUtil<Student> getSname(FenyeUtil<Student> fenye) {
		
		List<Student> data = studentmapper.getSname(fenye);
		if(data.size()>0) {
			fenye.setData(data);
		}else {
			fenye.setCode(1);
			fenye.setMsg("无数据");
		}
		
		return fenye;
	}
	
	

}
